<?php
/**
 * +--------------------------------------------------------------
 * | eLuoPHP
 * +--------------------------------------------------------------
 * | Copyright (c) 2016-2018 http://qxwoo.cn All rights reserved.
 * +--------------------------------------------------------------
 * | y139w [y139w@163.com]
 * +--------------------------------------------------------------
 * | Mysql数据库驱动类文件
 * +--------------------------------------------------------------
 */

namespace luo\db\driver;


use luo\db\Connection;

class Mysql extends Connection
{

    /**
     * 组装dsn链接
     * @param array $config
     * @return mixed|string
     */
    public function getDsn(array $config)
    {

        // pdo连接mysql时的dsn
        $dsn = 'mysql:dbname=' . $config['dbname'] . ';host=' . $config['host'];
        if (!empty($config['port'])) {
            $dsn .= ';port=' . $config['port'];
        } elseif (!empty($config['socket'])) {
            $dsn .= ';unix_socket=' . $config['socket'];
        }
        if (!empty($config['charset'])) {
            $dsn .= ';charset=' . $config['charset'];
        }
        return $dsn;

    }

}